let He2 = {
    validBlank: function (val) {
        return val !== null && val !== undefined && val !== '';
    },
    setData: function (_jq, val) {
        var self = this;
        if (!self.validBlank(val)) {
            console.log('he', '值为空');
            return;
        }
        //_jq.yyt('setVal', val);
        console.log('he', _jq.selector, val);
    },
    trigger: function (_jq) {
        var event = _jq.attr('event_type');
        if (event) {
            $.each(event.split(','), function () {
                _jq.trigger(this);
            });
        }
    },
    multiFieldVerify: function (resultDataArr, validArr) {
        for (var i = 0; i < resultDataArr.length; i++) {
            if (validArr.indexOf(resultDataArr[i]) === -1) {
                return false;
            }
        }
        return true;
    },
    getSourceDataResult: function (sourceData, directReturn) {
        if (directReturn) {
            return sourceData.report_details;
        }
        var result, report_details = sourceData.report_details, low_max_value = sourceData.low_max_value, high_max_value = sourceData.high_max_value;
        //结果为数字
        if (!isNaN(report_details)) {
            report_details = parseFloat(report_details), low_max_value = !isNaN(low_max_value) ? parseFloat(low_max_value) : '', high_max_value = !isNaN(high_max_value) ? parseFloat(high_max_value) : '';
            if (!low_max_value && high_max_value) {
                result = report_details <= high_max_value;
            } else if (low_max_value && !high_max_value) {
                result = report_details >= low_max_value;
            } else if (low_max_value && high_max_value) {
                result = report_details >= low_max_value && report_details <= high_max_value;
            } else {
                result = report_details;
            }
        } else {
            result = report_details;
        }
        return result;
    },
    exc(data, fieldMapArr) {
        $.each(fieldMapArr, function (index, fieldMap) {
            var el = fieldMap.el, destField = fieldMap.destField, sourceField = fieldMap.sourceField, directReturn = fieldMap.directReturn,
                verifyFun = fieldMap.verifyFun, validArr = fieldMap.validArr, valMap = fieldMap.valMap,
                triggerEvent = fieldMap.triggerEvent;
            var _jq = $(el + '[name="' + destField + '"]');
            if (_jq.length === 0) {
                _jq = $(el + '[compname="' + destField + '"]');
            }
            var multiSourceField = sourceField.split(',');
            if (multiSourceField.length > 1) {
                var resultDataArr = [];
                $.each(multiSourceField, function (i, v) {
                    var sourceData = data[v];
                    if (sourceData) {
                        var result = He2.getSourceDataResult(sourceData, directReturn);
                        resultDataArr.push(result);
                    }
                });
                if (resultDataArr.length > 0) {
                    var result = He2[verifyFun](resultDataArr, validArr);
                    //var val = (typeof result === 'boolean') ? (result ? passVal : refuseVal) : result;
                    var val = directReturn ? result : valMap[result];
                    He2.setData(_jq, val);
                    if (triggerEvent) {
                        He2.trigger(_jq);
                    }
                }
            } else {
                var sourceData = data[sourceField];
                if (sourceData) {
                    var result = He2.getSourceDataResult(sourceData, directReturn);
                    //var val = (typeof result === 'boolean') ? (result ? passVal : refuseVal) : result;
                    var val = directReturn ? result : valMap[result];
                    He2.setData(_jq, val);
                    if (triggerEvent) {
                        He2.trigger(_jq);
                    }
                }
            }
        });
    }
};
module.exports = He2;